//
//  RHMePlantInfoModel.m
//  RuiHeApp
//
//  Created by Yan Chen on 2025/1/4.
//

#import "RHMePlantInfoModel.h"
#import "RHMeOptionTypeModel.h"
#import "RHMeSystemModel.h"
#import "RHDeviceModel.h"

@implementation RHMePlantInfoModel
+ (NSDictionary *)modelContainerPropertyGenericClass {
    return @{@"optionList" : [RHMeOptionTypeModel class]};
 }

-(void)readInfo:(NSDictionary*)dic
{
    
    if (dic[self.key]) {
        if ([dic[self.key]isKindOfClass:[NSString class]]) {
            self.content = dic[self.key];
        }
        if ([dic[self.key]isKindOfClass:[NSNumber class]]) {
            self.content = [NSDecimalNumber decimalStringWithDouble:[dic[self.key] doubleValue]];
        }
        if ([dic[self.key]isKindOfClass:[NSArray class]]) {
            NSArray *arr = dic[self.key];
           
            if ([self.key isEqualToString:@"plantSystems"]) {
                self.plantSystems = [NSArray yy_modelArrayWithClass:[RHMeSystemModel class] json:arr];
                NSMutableString *mtbStr = [NSMutableString string];
                for (RHMeSystemModel *systemModel in self.plantSystems) {
                    [mtbStr appendString:ValidNullDataToString(systemModel.systemName, @"--")];
                    [mtbStr appendString:@","];
                }
                self.content = mtbStr.copy;
            }
            
            if ([self.key isEqualToString:@"deviceInfoList"]) {
                self.deviceInfoList = [NSArray yy_modelArrayWithClass:[RHDeviceModel class] json:arr];
                NSMutableString *mtbStr = [NSMutableString string];
                for (RHDeviceModel *devModel in self.deviceInfoList) {
                    [mtbStr appendString:ValidNullDataToString(devModel.deviceId, @"--")];
                    [mtbStr appendString:@","];
                }
                self.content = mtbStr.copy;
            }
        }
        
        if ([self.key isEqualToString:@"constructionTime"]) {//投建日期
            if (![dic[self.key] isEqual:[NSNull null]]) {
                self.content = [NSDate dateStringWithTimeInterval:[dic[self.key] integerValue]/1000 formatter:@"yyyy-MM-dd"];
            }else{
                self.content = @"--";
            }
            
        }
    }
   
}
@end
